<template>
  <div class="container">
    <!-- 顶部导航栏 - 改为更简洁的设计 -->
    <el-header class="header">
      <div class="logo-container" @click="router.push('/')">
        <img src="/src/static/logoa.png" alt="logo" class="logo-img" />
        <span class="logo-text">校园闲物欢乐市</span>
      </div>
      
      <div class="nav-container">
        <el-menu 
          class="nav-menu" 
          mode="horizontal" 
          :default-active="activeMenu" 
          @select="handleMenuSelect"
        >
          <el-menu-item index="/Index">首页</el-menu-item>
          <el-menu-item index="/Jiaoyi">交易市场</el-menu-item>
          <el-menu-item index="/PublishProduct">发布商品</el-menu-item>
          <!-- <el-menu-item index="/notice">校园公告</el-menu-item> -->
          <el-sub-menu index="categories">
            <template #title>商品分类</template>
            <el-menu-item 
              v-for="category in categories" 
              :key="category.id" 
              :index="'/category/' + category.id"
            >
              {{ category.name }}
            </el-menu-item>
          </el-sub-menu>
        </el-menu>
      </div>
      
      <div class="right-section">
        <div class="search-bar">
          <el-input 
            placeholder="搜索商品/用户..." 
            v-model="searchKeyword"
            clearable
            @keyup.enter="handleSearch"
            class="search-input"
          >
            <template #prefix>
              <el-icon><Search /></el-icon>
            </template>
          </el-input>
        </div>
        
        <div class="user-info">
          <el-dropdown v-if="userInfo.token" @command="handleUserCommand">
            <div class="user-avatar">
              <el-avatar :src="userInfo.avatar || '/src/static/default-avatar.png'" />
              <span class="user-name">{{ userInfo.nickname || userInfo.username }}</span>
            </div>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item command="profile">
                  <el-icon><User /></el-icon>个人中心
                </el-dropdown-item>
                <el-dropdown-item command="myItems">
                  <el-icon><Goods /></el-icon>我的商品
                </el-dropdown-item>
                <el-dropdown-item command="messages">
                  <el-icon><Message /></el-icon>消息中心
                </el-dropdown-item>
                <el-dropdown-item divided command="logout">
                  <el-icon><SwitchButton /></el-icon>退出登录
                </el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
          <div v-else class="auth-buttons">
            <el-button type="primary" plain @click="goLogin">登录</el-button>
            <el-button type="success" plain @click="goRegister">注册</el-button>
          </div>
        </div>
      </div>
    </el-header>

    <!-- 主要内容区域 -->
    <main class="main-content">
      <!-- 轮播图 - 添加半透明遮罩和更好的标题样式 -->
      <div class="banner-container">
        <el-carousel 
          class="banner" 
          :height="bannerHeight" 
          :autoplay="true" 
          :interval="5000"
          trigger="hover"
          arrow="always"
        >
          <el-carousel-item v-for="(item, index) in bannerList" :key="index">
            <div class="banner-overlay"></div>
            <img 
              :src="item.img" 
              alt="banner" 
              class="banner-img"
              @click="handleBannerClick(item.link)"
            >
            <div class="banner-content">
              <h3 class="banner-title">{{ item.title }}</h3>
              <p class="banner-desc">校园二手交易，让闲置物品重获新生</p>
              <el-button type="primary" round @click="handleBannerClick(item.link)">
                立即查看 <el-icon><ArrowRight /></el-icon>
              </el-button>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>

      <!-- 热门推荐 - 卡片样式优化 -->
      <div class="section hot-products">
        <div class="section-header">
          <div class="title-wrapper">
            <el-icon class="title-icon"><StarFilled /></el-icon>
            <h3 class="section-title">热门推荐</h3>
          </div>
          <el-link type="primary" :underline="false" @click="goMore('hot')" class="more-link">
            查看更多 <el-icon><ArrowRight /></el-icon>
          </el-link>
        </div>
        
        <div class="product-grid">
          <el-card 
            v-for="product in hotProducts" 
            :key="product.id" 
            class="product-card"
            shadow="hover"
            @click="goProductDetail(product.id)"
          >
            <div class="product-img-container">
              <img :src="product.coverImage" class="product-img" />
              <div class="product-tag" v-if="product.isNew">新品</div>
              <div class="product-status" v-if="product.status === 2">已售出</div>
              <div class="product-hover">
                <el-button type="primary" size="small" round>查看详情</el-button>
              </div>
            </div>
            <div class="product-info">
              <div class="product-name">{{ product.name }}</div>
              <div class="product-price">
                <span class="current-price">¥{{ product.price }}</span>
                <span class="original-price" v-if="product.originalPrice">
                  ¥{{ product.originalPrice }}
                </span>
              </div>
              <div class="product-meta">
                <span class="location">
                  <el-icon><Location /></el-icon>
                  {{ product.location }}
                </span>
                <span class="likes">
                  <el-icon><Star /></el-icon>
                  {{ product.likes }}
                </span>
              </div>
            </div>
          </el-card>
        </div>
      </div>

      <!-- 最新上架 - 改为横向滚动列表 -->
      <div class="section new-products">
        <div class="section-header">
          <div class="title-wrapper">
            <el-icon class="title-icon"><Clock /></el-icon>
            <h3 class="section-title">最新上架</h3>
          </div>
          <el-link type="primary" :underline="false" @click="goMore('new')" class="more-link">
            查看更多 <el-icon><ArrowRight /></el-icon>
          </el-link>
        </div>
        
        <div class="scroll-container">
          <div class="scroll-content">
            <div 
              v-for="product in newProducts" 
              :key="product.id" 
              class="new-product-item"
              @click="goProductDetail(product.id)"
            >
              <div class="product-img-wrapper">
                <img :src="product.coverImage" class="product-img" />
                <div class="time-badge">{{ formatTime(product.createTime) }}</div>
              </div>
              <div class="product-info">
                <div class="product-name">{{ product.name }}</div>
                <div class="product-bottom">
                  <span class="price">¥{{ product.price }}</span>
                  <div class="seller-info">
                    <el-avatar :size="24" :src="product.sellerAvatar" />
                    <span>{{ product.sellerName }}</span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>

    <!-- 底部信息 - 设计优化 -->
    <el-footer class="footer">
      <div class="footer-content">
        <div class="footer-column about-us">
          <div class="logo-container">
            <img src="/src/static/logoa.png" alt="logo" class="logo-img" />
            <span class="logo-text">校园闲物欢乐市</span>
          </div>
          <p class="footer-desc">
            连接校园，共享闲置，让每一件物品都能找到新的主人
          </p>
          <div class="social-links">
            <el-icon><ChatDotRound /></el-icon>
            <el-icon><Promotion /></el-icon>
            <el-icon><VideoCamera /></el-icon>
          </div>
        </div>
        
        <div class="footer-column links">
          <h4 class="footer-title">快速链接</h4>
          <ul>
            <li @click="goPage('/about')">关于我们</li>
            <li @click="goPage('/contact')">联系我们</li>
            <li @click="goPage('/help')">帮助中心</li>
            <li @click="goPage('/rules')">平台规则</li>
          </ul>
        </div>
        
        <div class="footer-column contact">
          <h4 class="footer-title">联系我们</h4>
          <ul>
            <li><el-icon><Phone /></el-icon> 客服电话: 123-456789</li>
            <li><el-icon><Message /></el-icon> 邮箱: contact@campus-trade.com</li>
            <li><el-icon><Location /></el-icon> 地址: XX大学学生活动中心</li>
          </ul>
        </div>
        
        <div class="footer-column qrcode">
          <h4 class="footer-title">关注我们</h4>
          <img src="https://img0.baidu.com/it/u=3584759695,3470619884&fm=253&fmt=auto&app=138&f=GIF?w=198&h=198" alt="公众号二维码" class="qrcode-img" />
          <p>扫描二维码关注公众号</p>
        </div>
      </div>
      
      <div class="copyright">
        © 2025 校园闲物欢乐市 版权所有 | ICP备案号: 京ICP备XXXXXX号
      </div>
    </el-footer>
  </div>
</template>

<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import axios from 'axios'
import { 
  Search, StarFilled, ArrowRight, Location, 
  Star, Clock, Phone, Message, User, Goods,
  SwitchButton, ChatDotRound, Promotion, VideoCamera
} from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'

const router = useRouter()

// 用户信息
const userInfo = ref({
  token: localStorage.getItem('token'),
  username: localStorage.getItem('username'),
  nickname: '校园用户',
  avatar: '',
  role: localStorage.getItem('userRole')
})

// 搜索功能
const searchKeyword = ref('')
const handleSearch = () => {
  if (!searchKeyword.value.trim()) {
    ElMessage.warning('请输入搜索关键词')
    return
  }
  router.push(`/search?keyword=${encodeURIComponent(searchKeyword.value)}`)
}

// 导航菜单
const activeMenu = ref('/home')
const categories = ref([
  { id: 1, name: '教材书籍' },
  { id: 2, name: '电子数码' },
  { id: 3, name: '服饰鞋包' },
  { id: 4, name: '生活用品' },
  { id: 5, name: '运动户外' }
])

const handleMenuSelect = (index) => {
  router.push(index)
}

// 用户操作
const handleUserCommand = (command) => {
  switch (command) {
    case 'profile':
      router.push('/PersonalCenter')
      break
    case 'myItems':
      router.push('/MyProduct')
      break
    case 'messages':
      router.push('/Xiaoxi')
      break
    case 'logout':
      handleLogout()
      break
  }
}

const handleLogout = () => {
  ElMessageBox.confirm('确定要退出登录吗?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    localStorage.removeItem('token')
    localStorage.removeItem('userRole')
    localStorage.removeItem('username')
    userInfo.value = {
      token: null,
      username: '',
      nickname: '',
      avatar: '',
      role: ''
    }
    ElMessage.success('已退出登录')
    router.push('/login')
  })
}

const goLogin = () => {
  router.push('/login')
}

const goRegister = () => {
  router.push('/register')
}

// 商品数据
const hotProducts = ref([])
const newProducts = ref([])
const bannerList = ref([])
const isLoading = ref(true) // 新增：加载状态

// 声明 bannerHeight 变量
const bannerHeight = ref('400px') // 初始值

// 从JSON Server获取数据
const fetchData = async () => {
  try {
    isLoading.value = true // 开始加载
    
    // 获取热门商品
    const hotRes = await axios.get('http://localhost:3000/hotProducts')
    hotProducts.value = hotRes.data
    
    // 获取最新商品
    const newRes = await axios.get('http://localhost:3000/newProducts?_sort=createTime&_order=desc')
    newProducts.value = newRes.data
    
    // 获取轮播图数据
    const bannerRes = await axios.get('http://localhost:3000/banners')
    bannerList.value = bannerRes.data
    
    // ElMessage.success('数据加载成功')
  } catch (error) {
    ElMessage.error('获取数据失败: ' + error.message)
    console.error('Error fetching data:', error)
  } finally {
    isLoading.value = false // 加载完成
  }
}

// 格式化时间
const formatTime = (timeString) => {
  const now = new Date()
  const time = new Date(timeString)
  const diffHours = Math.floor((now - time) / (1000 * 60 * 60))
  
  if (diffHours < 1) {
    return '刚刚'
  } else if (diffHours < 24) {
    return `${diffHours}小时前`
  } else {
    return time.toLocaleDateString()
  }
}

// 页面跳转
const goProductDetail = (id) => {
  router.push(`/product/${id}`)
}
const goMore = (type) => {
  router.push('/Jiaoyi')
}

const goPage = (path) => {
  router.push(path)
}

// 响应式调整
const updateDimensions = () => {
  // 轮播图高度
  const maxBannerHeight = window.innerHeight * 0.4
  bannerHeight.value = `${Math.min(maxBannerHeight, 500)}px`
}

// 合并 onMounted 钩子
onMounted(() => {
  fetchData()
  updateDimensions()
  window.addEventListener('resize', updateDimensions)
  
  // 设置当前激活菜单
  activeMenu.value = router.currentRoute.value.path
})

// 添加 onUnmounted 钩子移除事件监听器，防止内存泄漏
onUnmounted(() => {
  window.removeEventListener('resize', updateDimensions)
})
</script>

<style scoped lang="scss">
/* 基础样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 全局变量 */
:root {
  --primary-color: #ff6600;
  --primary-light: #ff944d;
  --primary-dark: #e65c00;
  --secondary-color: #4a90e2;
  --text-color: #333;
  --text-light: #666;
  --text-lighter: #999;
  --bg-color: #f8f9fa;
  --card-bg: #fff;
  --border-color: #eee;
  --success-color: #67c23a;
  --warning-color: #e6a23c;
  --danger-color: #f56c6c;
  --info-color: #909399;
}

/* 容器样式 */
.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-color);
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--text-color);
}

/* 头部导航栏样式 */
.header {
  background-color: var(--card-bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 40px;
  height: 70px;
  position: sticky;
  top: 0;
  z-index: 1000;
  
  .logo-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    
    .logo-img {
      width: 40px;
      height: 40px;
      margin-right: 12px;
    }
    
    .logo-text {
      font-size: 22px;
      font-weight: bold;
      color: var(--primary-color);
      letter-spacing: 1px;
    }
  }
  
  .nav-container {
    flex: 1;
    display: flex;
    justify-content: center;
    
    .nav-menu {
      border-bottom: none;
      
      :deep(.el-menu-item) {
        font-size: 16px;
        font-weight: 500;
        height: 68px;
        margin: 0 10px;
        color: var(--text-color);
        transition: all 0.3s ease;
        
        &:hover {
          color: var(--primary-color);
          background-color: transparent;
        }
        
        &.is-active {
          color: var(--primary-color);
          border-bottom: 3px solid var(--primary-color);
        }
      }
      
      :deep(.el-sub-menu__title) {
        font-size: 16px;
        height: 68px;
        color: var(--text-color);
        
        &:hover {
          color: var(--primary-color);
        }
      }
    }
  }
  
  .right-section {
    display: flex;
    align-items: center;
    
    .search-bar {
      margin-right: 30px;
      
      .search-input {
        width: 220px;
        
        :deep(.el-input__wrapper) {
          border-radius: 20px;
          padding: 0 15px;
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
          
          &:hover {
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
          }
        }
      }
    }
    
    .user-info {
  .user-avatar {
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none; /* 添加这行移除焦点边框 */
    
    &:hover {
      opacity: 0.8;
    }
    
    &:focus {
      outline: none; /* 确保焦点状态也没有边框 */
    }
    
    .el-avatar {
      background-color: var(--primary-light);
    }
    
    .user-name {
      margin-left: 8px;
      font-size: 14px;
      font-weight: 500;
    }
  }
}
    
    .auth-buttons {
      display: flex;
      gap: 10px;
      
      .el-button {
        padding: 8px 16px;
        font-weight: 500;
      }
    }
  }
}

/* 主要内容区域 */
.main-content {
  flex: 1;
  padding: 0 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* 轮播图样式 */
.banner-container {
  width: 100%;
  margin: 20px 0 40px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  
  .banner {
    border-radius: 12px;
    
    .banner-img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      cursor: pointer;
    }
    
    .banner-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(to right, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0) 100%);
    }
    
    .banner-content {
      position: absolute;
      top: 50%;
      left: 60px;
      transform: translateY(-50%);
      color: white;
      z-index: 2;
      max-width: 500px;
      
      .banner-title {
        font-size: 36px;
        font-weight: bold;
        margin-bottom: 15px;
        text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
      }
      
      .banner-desc {
        font-size: 18px;
        margin-bottom: 25px;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
      }
      
      .el-button {
        font-weight: 500;
        padding: 10px 24px;
        
        .el-icon {
          margin-left: 5px;
        }
      }
    }
    
    :deep(.el-carousel__indicators) {
      bottom: 30px;
      
      .el-carousel__indicator {
        padding: 0 6px;
        
        .el-carousel__button {
          width: 8px;
          height: 8px;
          border-radius: 50%;
          background-color: rgba(255,255,255,0.5);
          transition: all 0.3s;
        }
        
        &.is-active .el-carousel__button {
          width: 24px;
          border-radius: 4px;
          background-color: white;
        }
      }
    }
  }
}

/* 区块标题样式 */
.section {
  margin-bottom: 50px;
 background-color: #f6f7f8;
  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    
    .title-wrapper {
      display: flex;
      align-items: center;
      
      .title-icon {
        font-size: 24px;
        color: var(--primary-color);
        margin-right: 12px;
        
      }
      
      .section-title {
        font-size: 22px;
        font-weight: 600;
        color: var(--text-color);
         
      }
    }
    
    .more-link {
      display: flex;
      align-items: center;
      font-size: 14px;
      font-weight: 500;
      .el-icon {
        margin-left: 5px;
        transition: transform 0.3s;
      }
      
      &:hover .el-icon {
        transform: translateX(3px);
      }
    }
  }
}

/* 热门商品网格布局 */
.hot-products {
  .product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
  }
  
  .product-card {
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
    background-color: var(--card-bg);
    border: none;
    
    &:hover {
      transform: translateY(-5px);
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    }
    
    .product-img-container {
      position: relative;
      width: 100%;
      height: 200px;
      overflow: hidden;
      
      .product-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.5s ease;
      }
      
      .product-tag {
        position: absolute;
        top: 10px;
        left: 10px;
        background-color: var(--primary-color);
        color: white;
        padding: 3px 10px;
        border-radius: 10px;
        font-size: 12px;
        font-weight: 500;
        z-index: 1;
      }
      
      .product-status {
        position: absolute;
        top: 10px;
        right: 10px;
        background-color: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 3px 8px;
        border-radius: 4px;
        font-size: 12px;
        z-index: 1;
      }
      
      .product-hover {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.3s ease;
      }
    }
    
    &:hover .product-hover {
      opacity: 1;
    }
    
    .product-info {
      padding: 15px;
      
      .product-name {
        font-size: 15px;
        font-weight: 500;
        margin-bottom: 10px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        height: 42px;
        line-height: 1.4;
      }
      
      .product-price {
        display: flex;
        align-items: center;
        margin-bottom: 12px;
        
        .current-price {
          color: var(--primary-color);
          font-size: 18px;
          font-weight: bold;
        }
        
        .original-price {
          color: var(--text-lighter);
          font-size: 13px;
          text-decoration: line-through;
          margin-left: 8px;
        }
      }
      
      .product-meta {
        display: flex;
        justify-content: space-between;
        color: var(--text-light);
        font-size: 13px;
        
        .el-icon {
          margin-right: 4px;
          font-size: 14px;
        }
      }
    }
  }
}

/* 最新上架横向滚动布局 */
.new-products {
  .scroll-container {
    position: relative;
    overflow: hidden;
    
    .scroll-content {
      display: flex;
      gap: 20px;
      overflow-x: auto;
      padding-bottom: 20px;
      scrollbar-width: none; /* Firefox */
      
      &::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
      }
    }
  }
  
  .new-product-item {
    flex: 0 0 280px;
    background-color: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    cursor: pointer;
    
    &:hover {
      transform: translateY(-3px);
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    }
    
    .product-img-wrapper {
      position: relative;
      width: 100%;
      height: 160px;
      
      .product-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
      
      .time-badge {
        position: absolute;
        bottom: 10px;
        left: 10px;
        background-color: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 3px 8px;
        border-radius: 4px;
        font-size: 12px;
      }
    }
    
    .product-info {
      padding: 15px;
      
      .product-name {
        font-size: 15px;
        font-weight: 500;
        margin-bottom: 12px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        height: 42px;
        line-height: 1.4;
      }
      
      .product-bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        
        .price {
          color: var(--primary-color);
          font-size: 18px;
          font-weight: bold;
        }
        
        .seller-info {
          display: flex;
          align-items: center;
          
          .el-avatar {
            margin-right: 6px;
          }
          
          span {
            font-size: 13px;
            color: var(--text-light);
          }
        }
      }
    }
  }
}

/* 底部样式 */
.footer {
  background-color: #2c3e50;
  color: #ecf0f1;
  padding: 50px 0 20px;
  margin-top: 20px;
  
  .footer-content {
    background-color: #2c3e50;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 40px;
    max-width: 2000px;
    margin: 0 auto;
    padding: 0 40px;
    margin-bottom: -40px;
  }
  
  .footer-column {
    h4.footer-title {
      // background-color: #2c3e50;
      font-size: 18px;
      margin-bottom: 20px;
      position: relative;
      padding-bottom: 10px;
      
      &::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 40px;
        height: 2px;
        background-color: var(--primary-color);
      }
    }
    
    &.about-us {
      .logo-container {
        display: flex;
        align-items: center;
        margin-bottom: 15px;
        
        .logo-img {
          width: 36px;
          height: 36px;
          margin-right: 10px;
        }
        
        .logo-text {
          font-size: 18px;
          font-weight: bold;
          color: white;
        }
      }
      
      .footer-desc {
        
        font-size: 14px;
        line-height: 1.6;
        margin-bottom: 20px;
        color: #bdc3c7;
      }
      
      .social-links {
        display: flex;
        gap: 15px;
        
        .el-icon {
          font-size: 20px;
          color: #bdc3c7;
          cursor: pointer;
          transition: color 0.3s;
          
          &:hover {
            color: var(--primary-color);
          }
        }
      }
    }
    
    &.links {
      ul {
        list-style: none;
        
        li {
          margin-bottom: 12px;
          font-size: 14px;
          color: #bdc3c7;
          cursor: pointer;
          transition: all 0.3s;
          
          &:hover {
            color: var(--primary-color);
            transform: translateX(5px);
          }
        }
      }
    }
    
    &.contact {
      ul {
        list-style: none;
        
        li {
          margin-bottom: 12px;
          font-size: 14px;
          color: #bdc3c7;
          display: flex;
          align-items: center;
          
          .el-icon {
            margin-right: 8px;
            font-size: 16px;
          }
        }
      }
    }
    
    &.qrcode {
      .qrcode-img {
        width: 120px;
        height: 120px;
        margin-bottom: 10px;
        border: 1px solid #3d566e;
      }
      
      p {
        background-color: #2c3e50;
        font-size: 12px;
        color: #bdc3c7;
      }
    }
  }
  
  .copyright {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #3d566e;
    font-size: 12px;
    color: #7f8c8d;
  }
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .header {
    padding: 0 20px;
    
    .right-section .search-bar {
      margin-right: 15px;
      
      .search-input {
        width: 180px;
      }
    }
  }
  
  .main-content {
    padding: 0 20px;
  }
  
  .banner-container .banner .banner-content {
    left: 30px;
    
    .banner-title {
      font-size: 30px;
    }
    
    .banner-desc {
      font-size: 16px;
    }
  }
}

@media (max-width: 992px) {
  .header {
    flex-wrap: wrap;
    height: auto;
    padding: 15px 20px;
    
    .logo-container {
      order: 1;
    }
    
    .nav-container {
      order: 3;
      width: 100%;
      margin-top: 15px;
      
      .nav-menu {
        :deep(.el-menu-item),
        :deep(.el-sub-menu__title) {
          height: 50px;
          font-size: 14px;
          margin: 0 5px;
        }
      }
    }
    
    .right-section {
      order: 2;
      margin-left: auto;
      
      .search-bar {
        display: none;
      }
    }
  }
  
  .hot-products .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
  
  .footer .footer-content {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .banner-container {
    margin: 10px 0 30px;
    
    .banner .banner-content {
      left: 20px;
      
      .banner-title {
        font-size: 24px;
        margin-bottom: 10px;
      }
      
      .banner-desc {
        font-size: 14px;
        margin-bottom: 15px;
      }
    }
  }
  
  .section {
    margin-bottom: 30px;
    
    .section-header {
      .title-wrapper {
        .title-icon {
          font-size: 20px;
        }
        
        .section-title {
          font-size: 18px;
        }
      }
    }
  }
  
  .new-products .new-product-item {
    flex: 0 0 240px;
  }
}

@media (max-width: 576px) {
  .header {
    padding: 10px 15px;
    
    .logo-container .logo-text {
      font-size: 18px;
    }
    
    .nav-container {
      margin-top: 10px;
      
      .nav-menu {
        :deep(.el-menu-item),
        :deep(.el-sub-menu__title) {
          height: 40px;
          font-size: 13px;
          padding: 0 8px;
        }
      }
    }
    
    .right-section .user-info .user-name {
      display: none;
    }
  }
  
  .banner-container {
    .banner .banner-content {
      left: 15px;
      
      .banner-title {
        font-size: 20px;
      }
    }
  }
  
  .hot-products .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .new-products .new-product-item {
    flex: 0 0 200px;
    
    .product-info .product-name {
      font-size: 14px;
    }
  }
  
  .footer .footer-content {
    grid-template-columns: 1fr;
    gap: 30px;
  }
}
</style>